<template>
  <!--banner轮播-->
  <div class="swiper-container" ref="cur">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="(carousel) in carouselList" :key="carousel.id">
        <img class="imgSzie" :src="carousel.img_url" />
      </div>
    </div>
    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>
    <!-- 如果需要导航按钮 -->
    <div class="swiper-button-prev btnSize"></div>
    <div class="swiper-button-next btnSize"></div>
  </div>
</template>
<script>
import Swiper from "swiper";
export default {
  name: "mySwiper",
  props: ["carouselList"],
  watch: {
    // 监听的属性
    carouselList: {
      immediate: false,
      deep:false,
      handler() {
        this.$nextTick(() => {
          var mySwiper = new Swiper(this.$refs.cur,{
            loop: true,
            // 分页器
            pagination: {
              el: ".swiper-pagination",
              clickable: true
            },
            // 前进后退按钮
            navigation: {
              nextEl: ".swiper-button-next",
              prevEl: ".swiper-button-prev"
            }
          });
        });
      }
    }
  }
};
</script>
<style scoped>
.imgSzie{
  width: 100%;
}
.btnSize{
  font-size: 12px;
}
</style>>
